package com.example.syn;

import java.util.Random;
import java.util.concurrent.TimeUnit;

public class Customer implements Runnable {

    private String name;
    private WareHouse wareHouse;


    public Customer(String name, WareHouse wareHouse) {
        this.wareHouse = wareHouse;
        this.name = name;
    }

    @Override
    public void run() {
        while (true) {
            Goods goods = wareHouse.get();
            System.out.println(name + " customer get: " + goods);
            try {
                TimeUnit.SECONDS.sleep(new Random().nextInt(7));
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}
